<?php
/*
 * File name:product.php
 * Create by DucNN
 * Create date: 06/11/2012
 */
class Product extends DataMapper {    
    public $has_many = array(
        'productmeta' => array("productmeta"),
        'term_taxonomy' => array(			
            'class' => 'term_taxonomy',			
            'other_field' => 'product',		
            'join_self_as' => 'product',		
            'join_other_as' => 'term_taxonomy',		
            'join_table' => 'hd_term_taxonomies_products'
        ),
        'order' => array(			
            'class' => 'order',			
            'other_field' => 'product',		
            'join_self_as' => 'product',		
            'join_other_as' => 'order',		
            'join_table' => 'hd_orders_products'
        )	
    );
    public function __construct()
    {
        // model constructor
        parent::__construct();
    }  
    function get_productmeta($product_id,$meta_key = '')
    {
        $product_meta = new Productmeta();
        $product_meta->where('product_id', $product_id)
                ->where('meta_key', $meta_key)
                ->get();
        return $product_meta->meta_value;
    } 
}
?>